package bsts.model;

import java.io.Serializable;
import java.util.ArrayList;

public abstract class Plan implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private long planId;
	private String name;
	private String description;
	
	private ArrayList<Feature> features;
	
	public Plan(long planId, String name, String description) {
		this.planId = planId;
		this.name = name;
		this.description = description;		
		this.features = new ArrayList<Feature>();
	}
	public Plan(String name, String description) {		
		this.name = name;
		this.description = description;		
		this.features = new ArrayList<Feature>();
	}

	public long getPlanId() {
		return planId;
	}

	public void setPlanId(long planId) {
		this.planId = planId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	public boolean addFeature(Feature feature) {
		return features.add( feature );
	}
	public void setFeatures(ArrayList<Feature> features) {
		this.features = features;
	}
	public boolean removeFeature(Feature feature) {
		return features.remove( feature );
	}
	
	public ArrayList<Feature> getFeatures() {
		return features;
	}
	
	@SuppressWarnings("unchecked")
	public ArrayList<Feature> getFeaturesClone() {
		return (ArrayList<Feature>) features.clone();
	}
	
	public void terminateFeatures() {
		for (Feature feature : features) {
			if (feature.getSubscriptionStatus().equals(SubscriptionStatus.Activated)) {
				feature.setSubscriptionStatus(SubscriptionStatus.Terminated);
			}
		}
	}
	
	public abstract Plan clone();
	
}
